<template>
  <body>
    <div class="header">
      <div class="mainwarp">
        <div class="logo">
          <a href="index.html"><img src="@/assets/images/log.png" /></a>
        </div>
        <div class="welcome">欢迎登录</div>
        <div class="headerright">
          <router-link to="/Home" class="header-link">返回首页</router-link>
        </div>
      </div>
    </div>
    <div class="content">
      <div class="logtype"></div>
      <div class="clear"></div>
      <div class="logoDiv">
        <div class="logoLeft">
          <div class="leftimg">
            <img src="@/assets/images/log1.gif" />
          </div>
          <div class="leftcon">
            <a href="" class="a1">手机触屏版</a>
            <a href="" class="a2">Android客户端下载</a>
            <a href="" class="a3">iPhone客户端下载</a>
          </div>
        </div>
        <div class="logoRight">
          <div class="normalLogin">
            <el-form :model="user" :rules="rules" ref="user">
              <el-form-item label="账号" prop="username">
                <el-input
                  type="text"
                  v-model="user.username"
                  placeholder="请输入账号"
                />
              </el-form-item>
              <el-form-item label="密码" prop="password">
                <el-input
                  type="password"
                  v-model="user.password"
                  placeholder="请输入密码"
                  @keyup.enter="userLogin"
                />
              </el-form-item>
            </el-form>

            <div class="checkbox-container">
              <el-checkbox
                v-model="checked5"
                label="我已阅读并接受"
                size="small"
                class="custom-checkbox"
              ></el-checkbox>
              <router-link to="/agreement" class="user-agreement"
                >用户协议</router-link
              >
              <router-link to="/forgetPassword" class="forgot-password"
                >忘记密码？</router-link
              >
            </div>

            <div class="logobtn">
              <a
                href="#"
                @click="userLogin"
                class="login-btn"
                :disabled="isDisabled"
                >登 录</a
              >
            </div>
            <div class="zcbtn">
              <router-link to="/register">还没有账号？立即注册</router-link>
            </div>
          </div>
          <div class="weixinLogin">
            <div class="weixinQr">
              <img
                src="@/assets/images/showqrcode.jpg"
                width="150"
                class="useHelpcon"
              />
              <p>使用微信扫描上方二维码</p>
              <p class="useHelp useHelpcon">使用帮助</p>
            </div>
            <div class="zcbtn">
              <a href="register.html">还没有账号？立即注册</a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="clear"></div>
  </body>
</template>
<script>
import { ElMessage } from "element-plus";

export default {
  name: "login",
  data() {
    return {
      user: {
        username: "",
        password: "",
      },
      rules: {
        username: [
          {
            required: true,
            message: "账号不能为空",
            trigger: "blur",
          },
          {
            min: 5,
            max: 20,
            message: "账号必须在5到20位",
            trigger: "blur",
          },
        ],
        password: [
          {
            required: true,
            message: "密码不能为空",
            trigger: "blur",
          },
          {
            min: 5,
            max: 15,
            message: "密码必须在5到15位 ",
            trigger: "blur",
          },
        ],
      },
      isDisabled: false,
      checked5: false,
    };
  },
  methods: {
    /**
     * 用户登录
     *
     * 登录后跳转主页
     */
    userLogin() {
      if (!this.checked5) {
        ElMessage.warning("请先阅读并接受用户协议");
      } else {
        this.isDisabled = true;
        // 如果已勾选用户协议，则进行登录操作
        this.$store
          .dispatch("LOGIN", this.user)
          .then(() => {
            //解除禁用
            this.isDisabled = false;
            // 登录成功，跳转到首页
            this.$router.push({ name: "Home" });
          })
          .catch((err) => {
            this.isDisabled = false;
            // 显示错误消息
            const errorMessage = err.data?.message || "登录失败，请重试";
            ElMessage.error(errorMessage);
          });
      }
    },
  },
};
</script>

<style scoped>
@charset "utf-8";

/* CSS Document */
* {
  margin: 0;
  padding: 0;
}
ul li {
  list-style: none;
}
a {
  text-decoration: none;
}
img {
  border: 0;
  max-height: 100%;
  max-width: 100%;
}
body {
  width: 100%;
  min-width: 1200px;
  margin: 0 auto;
  font-size: 12px;
  font-family: "微软雅黑";
  color: #222;
  background: #fff4f0;
}
.clear {
  clear: both;
}
input {
  border: 0;
  outline: 0;
}

.header {
  height: 85px;
  width: 100%;
  background: #fff;
  border-bottom: #fee7b1 1px solid;
}
.mainwarp {
  width: 1000px;
  margin: 0 auto;
}
.header .logo {
  float: left;
  margin-top: 20px;
}
.header .welcome {
  float: left;
  margin-top: 20px;
  height: 40px;
  border-left: 1px solid #f4f4f4;
  padding-left: 15px;
  margin-left: 10px;
  line-height: 40px;
  font-size: 22px;
  color: #5c5c5c;
}
.header .headerright {
  float: right;
  font-size: 14px;
  margin-top: 20px;
  padding-top: 15px;
}
.header .headerright a {
  color: #343434;
}
.header .headerright span {
  color: #dadada;
  margin-left: 10px;
  margin-right: 10px;
}

.content {
  width: 1000px;
  margin: 40px auto;
  background: #fff;
  border: 1px #fee7b5 solid;
  margin-top: 50px;
  height: 500px;
  margin-top: 20px;
}
.logtype {
  float: right;
  width: 53px;
  height: 53px;
  cursor: pointer;
}
.logtype.on {
  background: url(@/assets/images/log2.png) no-repeat;
}

.logoDiv .logoLeft {
  float: left;
  width: 636px;
}
.logoDiv .logoLeft .leftimg {
  width: 601px;
  margin: 0 auto;
}
.logoDiv .logoLeft .leftcon {
  text-align: center;
  color: #838385;
  margin-top: 10px;
}
.logoDiv .logoLeft .leftcon a {
  display: inline-block;
  color: #838385;
  padding-left: 20px;
  margin-left: 20px;
  height: 18px;
}
.logoDiv .logoLeft .leftcon a.a1 {
  background: url(@/assets/images/log3.png) no-repeat;
}
.logoDiv .logoLeft .leftcon a.a2 {
  background: url(@/assets/images/log4.png) no-repeat;
}
.logoDiv .logoLeft .leftcon a.a3 {
  background: url(@/assets/images/log5.png) no-repeat;
}
.logoDiv .logoRight {
  float: left;
  width: 363px;
  border-left: 1px solid #e8e8e8;
  height: 365px;
}

.normalLogin {
  width: 288px;
  margin: 0 auto;
}
.normalLogin .username {
  background: url(@/assets/images/log6.png) no-repeat;
  height: 42px;
  margin-top: 5px;
}
.normalLogin .username span {
  background: url(@/assets/images/log7.png) no-repeat;
  width: 51px;
  height: 40px;
  float: left;
  margin-top: 1px;
}
.normalLogin .username input {
  float: left;
  background: none;
  width: 226px;
  margin-top: 1px;
  color: #757776;
  font-size: 14px;
  padding-left: 10px;
  line-height: 40px;
  height: 40px;
}
.normalLogin .password {
  background: url(@/assets/images/log6.png) no-repeat;
  height: 42px;
  margin-top: 25px;
  margin-bottom: 25px;
}
.normalLogin .password span {
  background: url(@/assets/images/log8.png) no-repeat;
  width: 51px;
  height: 40px;
  float: left;
  margin-top: 1px;
}
.normalLogin .password input {
  float: left;
  background: none;
  width: 226px;
  margin-top: 1px;
  color: #757776;
  font-size: 14px;
  padding-left: 10px;
  line-height: 40px;
  height: 40px;
}
.normalLogin .autoLogo {
  font-size: 14px;
  margin-top: 10px;
}
.CheckBox {
  display: block;
  float: left;
  width: 16px;
  height: 16px;
  background: url(@/assets/images/log11.png) no-repeat;
}
.CheckBox:hover {
  background: url(@/assets/images/log10.png) no-repeat;
}
.CheckBox.Yes {
  background: url(@/assets/images/log9.png) no-repeat;
}
.normalLogin .autoLogo span {
  vertical-align: middle;
  font-size: 12px;
  padding-right: 5px;
}
.normalLogin .autoLogo span a {
  color: #0f72a4;
}
.normalLogin .autoLogo a.pasd {
  float: right;
  color: #0485c7;
  vertical-align: middle;
  font-size: 14px;
}
.normalLogin .logobtn {
  margin-top: 10px;
  width: 288px;
  height: 42px;
  background: #ff7a4d;
  font-size: 20px;
  border-radius: 4px;
  line-height: 42px;
  text-align: center;
}
.normalLogin .logobtn a {
  display: block;
  color: #fff;
}
.zcbtn {
  text-align: center;
  margin-top: 30px;
  font-size: 14px;
  height: 40px;
  line-height: 40px;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}
.zcbtn a {
  display: block;
  color: #9b9b9b;
}
.thirdLogin {
  color: #676767;
  margin-top: 15px;
  font-size: 14px;
}

.thirdLogin .third .third_con {
  float: left;
  background-color: #fbfbfb;
  border: 1px #eeeeee solid;
  padding: 5px 6px 5px 32px;
  cursor: pointer;
  margin-top: 10px;
}
.thirdLogin .third .third_1 {
  background: url(@/assets/images/log12.png) 5px center no-repeat;
}
.thirdLogin .third .third_2 {
  background: url(@/assets/images/log13.png) 5px center no-repeat;
  margin-left: 7px;
}
.thirdLogin .third .third_3 {
  background: url(@/assets/images/log14.png) 5px center no-repeat;
  margin-left: 7px;
}

.weixinLogin {
  width: 288px;
  margin: 0 auto;
  display: none;
}
.weixinLogin .weixinQr {
  text-align: center;
}
.weixinLogin .weixinQr img {
  width: 150px;
  height: 150px;
  border: 1px #eaeaea solid;
}
.weixinLogin .weixinQr p {
  color: #333333;
  line-height: 30px;
}
.weixinLogin .weixinQr p.useHelp {
  background: url(@/assets/images/log15.png) 2px 7px no-repeat;
  color: #fa6803;
  display: inline-block;
  padding-left: 17px;
  cursor: pointer;
  width: 52px;
}
.usehelpimg {
  position: absolute;
  top: 100px;
  z-index: 100;
  left: 50%;
  opacity: 0;
  margin-left: 30px;
  display: none;
}

.footer {
  padding-top: 20px;
  padding-bottom: 20px;
  clear: both;
  margin: 20px auto 0 auto;
  border-top: 1px #e2e2e2 solid;
  text-align: center;
}
.footer a {
  color: #3364cb;
  padding-left: 5px;
  padding-right: 5px;
}

/*用户协议*/
.registerMain {
  font-size: 12px;
  line-height: 24px;
  background-color: #f9eedd;
  padding: 20px;
  border: 1px dashed #fe6b07;
  width: 700px;
  margin-right: auto;
  margin-left: auto;
  margin-top: 1px;
}
.registerMain h1 {
  color: #ff3300;
  text-align: center;
  padding-bottom: 20px;
  padding-top: 10px;
}
.registerMain span {
  font-weight: bold;
  color: #ff3300;
  margin-left: 20px;
}
.registerMain .con {
  margin-right: 20px;
  margin-left: 40px;
}

/*忘记密码*/
.passdBox {
  width: 1000px;
  margin: 40px auto;
  background: #fff;
  border: 1px #fee7b5 solid;
  margin-top: 50px;
  padding-bottom: 50px;
}
.passdBox .passpart1 {
  width: 800px;
  margin: 0 auto;
}
.passdBox .passpart1 .TitleNotice {
  font-family: "微软雅黑";
  margin-top: 50px;
  font-size: 16px;
}
.passdBox .passpart1 .StepsBox {
  margin-top: 45px;
  width: 100%;
  height: 6px;
  background: #d9d9d9;
  border-radius: 3px;
}
.passdBox .passpart1 .StepsBox .Step {
  width: 25%;
  text-align: center;
  float: left;
}
.passdBox .passpart1 .StepsBox .Step.Active {
  height: 6px;
  background: #00c61b;
}
.passdBox .passpart1 .StepsBox .Step.stepfirst {
  border-radius: 3px 0px 0px 3px;
}
.passdBox .passpart1 .StepsBox .Step.steplast {
  border-radius: 0px 3px 3px 0px;
}
.passdBox .passpart1 .StepsBox .Step.Active .StepNo {
  background: url(@/assets/images/log17.png) no-repeat;
}
.passdBox .passpart1 .StepsBox .Step.Active .StepName {
  color: #00c61b;
}
.passdBox .passpart1 .StepsBox .Step span {
  margin: 0 auto;
  display: block;
}
.passdBox .passpart1 .StepsBox .Step .StepNo {
  width: 23px;
  background: url(@/assets/images/log18.png) no-repeat;
  height: 23px;
  line-height: 23px;
  top: -8px;
  position: relative;
  color: #fff;
  font-family: Arial;
  font-weight: bold;
  font-size: 14px;
}
.passdBox .passpart1 .StepsBox .Step .StepName {
  color: #aeaeae;
  font-family: "宋体";
}
.passdBox .passpart1 .StepsBox .Step.steplast .StepNo {
  background: url(@/assets/images/log19.png) no-repeat;
}
.passdBox .passpart1 .StepsBox .Step.steplast.Active .StepNo {
  background: url(@/assets/images/log20.png) no-repeat;
}
.passdBox .passpart1 .restInfo {
  font-size: 14px;
  width: 326px;
  margin: 0 auto;
  margin-top: 40px;
}
.passdBox .passpart1 .restInfo .box1 {
  margin-bottom: 20px;
}
.passdBox .passpart1 .restInfo .box1 span {
  display: block;
  float: left;
  line-height: 35px;
  width: 70px;
  text-align: right;
}
.passdBox .passpart1 .restInfo .box1 input {
  display: block;
  float: left;
  padding: 0;
  width: 233px;
  height: 35px;
  border: 1px #dbdbdb solid;
  border-radius: 4px;
  padding-left: 10px;
  line-height: 35px;
  background: none;
  vertical-align: middle;
  padding-right: 10px;
  font-size: 14px;
  color: #9a9a9c;
}
.passdBox .passpart1 .restInfo .box1 input.yzm {
  width: 128px;
  margin-right: 5px;
}
.passdBox .passpart1 .restInfo .box1 input.onebtn {
  height: 37px;
  background: #ff6f3d;
  color: #fff;
  font-size: 16px;
  border: none;
  width: 140px;
  border-radius: 4px;
  cursor: pointer;
  margin: 0 auto;
  float: none;
}
.passdBox .passpart1 .restInfo .box2 {
  padding: 10px 0px;
}
.passdBox .passpart1 .restInfo b.phonenum {
  display: block;
  font-weight: normal;
  float: left;
  width: 88px;
  height: 35px;
  line-height: 35px;
  background: #ffe6d7;
  color: #eb7351;
  border: 1px solid #f3cfb7;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
}
.passdBox .passpart1 .restInfo .box2 span.span1 {
  display: block;
  float: left;
  line-height: 35px;
  width: 70px;
  text-align: right;
}
.passdBox .passpart1 .restInfo .box2 span.span2 {
  display: block;
  float: left;
  width: 233px;
  height: 35px;
  line-height: 35px;
}
.passdBox .passpart1 .restInfo2 {
  padding-top: 70px;
}
.passdBox .passpart1 .restInfo2 .SucTitle {
  font-size: 20px;
  padding-left: 50px;
  margin-left: 230px;
  font-weight: bold;
  background: url(@/assets/images/log21.png) no-repeat;
  height: 42px;
  line-height: 42px;
}
.passdBox .passpart1 .restInfo2 p {
  font-family: "微软雅黑";
  text-align: center;
  font-size: 14px;
  margin-top: 15px;
}
.passdBox .passpart1 .restInfo2 a {
  color: #0f72a4;
  margin-left: 3px;
}

/*注册*/
.zhuceBox {
  width: 880px;
  margin: 0 auto;
  background: #fff;
  height: 459px;
  border: 1px solid #fee7b1;
  margin-top: 25px;
  margin-bottom: 50px;
  font-family: "微软雅黑";
}
.zhuceBox .zcLeft {
  float: left;
  width: 547px;
  border-right: 1px solid #ccc;
  height: 100%;
}

.zhuceBox .zcLeft ul#tabzc li {
  background: #f0f0f0;
  float: left;
  width: 273px;
  height: 52px;
  line-height: 52px;
  cursor: pointer;
  color: #353535;
  text-align: center;
  font-size: 16px;
  border-left: 1px solid #d4d4d4;
}
.zhuceBox .zcLeft ul#tabzc li:first-child {
  border-left: 0;
}
.zhuceBox .zcLeft ul#tabzc li.currentzc {
  cursor: inherit;
  background: #fff;
}

.zhuceBox .zcLeft #contentzc .zcpart1 {
  background: url(@/assets/images/log23.png) no-repeat;
  width: 272px;
  height: 37px;
  margin: 20px auto 0px auto;
}
.zhuceBox .zcLeft #contentzc .zcpart2 {
  width: 272px;
  margin: 30px 0px 0px 160px;
}
.zcpart2_l {
  float: left;
}
.zcpart2_l img {
  border: 1px solid rgb(234, 234, 234);
}
.zcpart2_r {
  float: left;
}
.zcpart2_r img {
  margin-top: 35px;
}
.zcpart2_c {
  margin-top: 20px;
  font-size: 12px;
  font-family: "宋体";
}
.zcpart2_c a {
  color: #0f72a4;
}
.zhuceBox .zcLeft #contentzc ul {
  display: none;
}
.zhuceBox .zcLeft #contentzc .zcpart3 {
  width: 265px;
  height: 20px;
  margin: 30px auto 0px auto;
}
.zhuceBox .zcLeft #contentzc .zcpart3 .zcstep {
  display: inline-block;
  width: 35px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  background: #f5f5f5;
  border: 1px solid #e7e7e7;
}
.zhuceBox .zcLeft #contentzc .zcpart3 .zcstepGo {
  background: url(@/assets/images/log25.png) 5px center no-repeat;
  display: inline-block;
  width: 12px;
  height: 20px;
  vertical-align: middle;
}
.zhuceBox .zcLeft #contentzc .zcpart3 .zcstepLast {
  display: inline-block;
  width: 85px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  background: #f5f5f5;
  border: 1px solid #e7e7e7;
}
.zhuceBox .zcLeft #contentzc .zcpart4 {
  width: 285px;
  margin: 20px auto;
}
.zhuceBox .zcLeft #contentzc .zcpart0 {
  margin-left: 105px;
}
.zhuceBox .zcLeft #contentzc .zcpart5 {
  margin-top: 25px;
  background: url(@/assets/images/log6.png) no-repeat;
  height: 42px;
  margin-top: 35px;
  margin-bottom: 5px;
}
.zhuceBox .zcLeft #contentzc .zcpart5 span {
  background: url(@/assets/images/log7.png) no-repeat;
  width: 51px;
  height: 40px;
  float: left;
  margin-top: 1px;
}
.zhuceBox .zcLeft #contentzc .zcpart5 input {
  float: left;
  background: none;
  width: 226px;
  margin-top: 1px;
  color: #757776;
  font-size: 14px;
  padding-left: 10px;
  line-height: 40px;
  height: 40px;
}
.zhuceBox .zcLeft #contentzc .zcpart6 {
  margin-left: 55px;
  padding-left: 20px;
  display: block;
  background: url(@/assets/images/log26.png) no-repeat;
  display: inline-block;
  line-height: 16px;
  color: #757776;
  height: 20px;
}
.zhuceBox .zcLeft #contentzc .zcpart7 {
  margin-top: 25px;
  background: url(@/assets/images/log6.png) no-repeat;
  height: 42px;
  margin-top: 5px;
  margin-bottom: 5px;
}
.zhuceBox .zcLeft #contentzc .zcpart7 span {
  background: url(@/assets/images/log27.png) no-repeat;
  width: 51px;
  height: 40px;
  float: left;
  margin-top: 1px;
}
.zhuceBox .zcLeft #contentzc .zcpart7 input {
  float: left;
  background: none;
  width: 226px;
  margin-top: 1px;
  color: #757776;
  font-size: 14px;
  padding-left: 10px;
  line-height: 40px;
  height: 40px;
}
.zcpart8 {
  margin-top: 10px;
  width: 333px;
  height: 42px;
  background: #ff7a4d;
  font-size: 18px;
  font-family: "微软雅黑";
  border-radius: 4px;
  line-height: 42px;
  text-align: center;
}
.zcpart8 a {
  display: block;
  color: #fff;
}
.zcpart8.zcpart9 {
  background: #fff;
  border: 1px solid #dfdfdf;
  font-size: 15px;
}
.zcpart9 a {
  display: block;
  color: #757776;
}
.zhuceBox .zcRight {
  float: left;
  background: url(@/assets/images/log22.png) no-repeat;
  width: 330px;
  text-align: center;
  height: 100%;
}
.zhuceBox .zcRight .topdiv {
  height: 116px;
  padding-top: 50px;
  font-family: 微软雅黑;
}
.zhuceBox .zcRight .topdiv .noPa {
  font-size: 18px;
  color: #000;
}
.zhuceBox .zcRight .topdiv a {
  width: 150px;
  height: 40px;
  background: #fa6d01;
  display: inline-block;
  line-height: 40px;
  font-size: 16px;
  border-radius: 5px;
  margin-top: 20px;
  color: #fff;
}
/* 新增 */
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 10px; /* 设置元素之间的间距 */
}

.custom-checkbox .el-checkbox__label {
  font-size: 14px; /* 调整字体大小 */
  color: #333; /* 调整字体颜色 */
}

.user-agreement {
  text-decoration: none; /* 移除下划线 */
  color: #007bff; /* 设置链接颜色 */
}

.user-agreement:hover {
  text-decoration: underline; /* 添加悬停效果 */
}

.forgot-password {
  text-decoration: none; /* 移除下划线 */
  color: #dc3545; /* 设置链接颜色 */
  margin-left: 10px; /* 增加左边距 */
}

.forgot-password:hover {
  text-decoration: underline; /* 添加悬停效果 */
}

.forgot-password-wrapper {
  margin-left: auto; /* 使“忘记密码？”链接右对齐 */
}
/* 新增 注册*/
.zcbtn {
  text-align: center;
  margin-top: 30px;
  font-size: 14px;
  height: 40px;
  line-height: 40px;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.zcbtn a {
  display: block;
  color: #9b9b9b; /* 默认颜色 */
  text-decoration: none; /* 移除下划线 */
}

.zcbtn a:hover {
  color: #ff7a4d; /* 鼠标悬停时的高亮颜色 */
  text-decoration: underline; /* 添加下划线 */
}
/*新增 返回首页和登录 */
.login-btn {
  display: block;
  width: 100%;
  height: 42px;
  background: #ff7a4d; /* 登录按钮背景色 */
  font-size: 20px;
  border-radius: 4px;
  line-height: 42px;
  text-align: center;
  color: #fff; /* 登录按钮文字颜色 */
  text-decoration: none; /* 移除下划线 */
}

.login-btn:hover {
  background: #ffcc99; /* 鼠标悬停时的背景色 */
  color: #ff6633; /* 鼠标悬停时的文字颜色 */
  text-decoration: none; /* 移除下划线，可以使用其他效果如加粗或边框 */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* 添加阴影效果 */
}

/* 返回首页路由链接悬停效果 */
.header-link {
  color: #343434; /* 默认颜色 */
  text-decoration: none; /* 移除下划线 */
}

.header-link:hover {
  color: #ff7a4d; /* 鼠标悬停时的高亮颜色 */
  text-decoration: underline; /* 添加下划线 */
}
</style>